<template>
  <div id="app">
    <Header></Header>
    <el-container>
      <Aside></Aside>
      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </div>
</template>

<script>
import Header from '@/components/Header/index'
import Aside from '@/components/Aside/index'
  export default {
    created() {
      this.getData()
    },
    methods: {
      // 获取疫情分布全部数据
      async getData() {
        await this.$axios.get('http://localhost:8080/api').then((res) => {
          let todayDetailList = res.data.showapi_res_body.todayDetailList
          let showapi_res_body = res.data.showapi_res_body
          let arr = []
          for(let i = 0; i < todayDetailList.length; i++) {
            let obj = {}
            if(todayDetailList[i].provinceName == '黑龙江省') {
              obj.name = todayDetailList[i].provinceName.substring(0,3)
            }else if( todayDetailList[i].provinceName == '内蒙古自治区' ) {
              obj.name = todayDetailList[i].provinceName.substring(0,3)
            }else {
              obj.name = todayDetailList[i].provinceName.substring(0,2)
            }
            obj.value = todayDetailList[i].confirmedNum
            arr.push(obj)
          }
          localStorage.setItem('confirmedNum', JSON.stringify(arr))
          localStorage.setItem('showapi_res_body', JSON.stringify(showapi_res_body))
        }).catch((err) => {
          console.log(err);
        })
      },
    },
    components: {
      Header,
      Aside
    }
  }
</script>

<style lang="scss" scoped>
#app {
  height: 100vh;
  .el-container {
    height: 93.5%;
    .el-main {
      height: 100%;
    }
  }
}
</style>